<!-- eslint-disable vue/multi-word-component-names -->
<template>
  <div class="father">
    <el-page-header @back="goBack" content="购买页面" class="header"></el-page-header>
    <div class="body">
      <div>
        <div class="body-item1">
          <el-image style="width: 450px" :src="url" :preview-src-list="srcList">
          </el-image>
        </div>
        <div class="body-item2">
          <div class="item2-item1">
            <div class="item1-content1">
              <h3>[爆款回归]华为智选 海雀智能摄像头</h3>
            </div>
            <div class="item1-content2">
              <div>销售价：￥469</div>
              <div>
                <p> 销售数量
                  <button @click="num == 0 ? 0 : num --">-</button>
                  <button>{{ num }}</button>
                  <button @click="num++">+</button>
                </p>
              </div>
              <div class="money">所需金额：￥{{ total }}</div>
              <div class="content2-item3"><button class="item3-button" @click="pay">立即购买</button><button
                  class="item3-button" @click="addShopcart">加入购物车</button></div>
            </div>
          </div>
          <div class="item2-item2">
            <div class="item2-content1">
              <h3>商品参数</h3>
            </div>
            <div class="item2-content2">
              <p>华为智选生态产品是华为推出的生态共创产品品牌，由华为甄选优秀合作伙伴共同为消费者打造优质的智能硬件产品，
                既是垂域创新、高级设计感和高质量的代表，也是便捷、智能的鸿蒙智联生态硬件的精品。</p>
              <p>臻4K影院级画质内置128G海雀．芯存储AI 智能2.0智慧生活新纪元</p>
              <p>搭载高性能双核芯片和专业级 CMOS 图像传感器分辨率高达3840*2160P,800万像素大屏画面毫厘毕现。</p>
              <p>支持 APP 类型：华为智慧生活 App ，自有 App </p>
              <p>WIFI 频段：2.4G</p>
              <p>语音类型：语音通话</p>
              <p>变倍变焦：不支持变焦</p>
              <p>设备类型：家用云台</p>
              <p>智能识别：人形识别，移动监测等</p>
              <p>像素：800万</p>
              <p>顾</p>
              <p>客</p>
              <p>朋</p>
              <p>友</p>
              <p>快</p>
              <p>来</p>
              <p>购</p>
              <p>买</p>
              <p>吧</p>
              <p>！</p>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="hello_world">
      <button class="top" @click="toTop">
        <img src="@/assets/backToTop.png" width="100%">
      </button>
    </div>
  </div>
</template>

<script>
  import BScroll from 'better-scroll'
  export default {
    name: 'z_seven_shop',
    data() {
      return {
        num: 0,
        url: require('@/assets/l-she-zhu.png'),
        srcList: [
          require('@/assets/l-she-zhu.png')
        ]
      }
    },
    methods: {
      goBack() {
        this.$router.go(-1)
      },
      toTop() {
        window.location.reload()
      },
      sunAdd() {
        this.num = this.num + 1
      },
      sumDelete() {
        if (this.num === 0) {
          this.num = this.num - 0
        } else {
          this.num = this.num - 1
        }
      },
      addShopcart() {
        this.$store.commit('shopcart/addShopcart', {
          id: 100,
          count: parseInt(this.num),
          url: require('@/assets/l-she-zhu.png'),
          price: 469,
          detail: '智能摄像头',
          selected: true,
          path: '/h_walk/l-tiaozhuan2-1'
        })
      },
      pay() {
        this.$router.push({
          name: 'pay',
          params: {
            detail: {
              id: 100,
              count: parseInt(this.num),
              url: require('@/assets/l-she-zhu.png'),
              price: 469,
              detail: '智能摄像头',
              selected: true,
              path: '/h_walk/l-tiaozhuan2-1'
            }
          }
        })
        this.$store.state.onHomePage = false
      }

    },

    computed: {
      total() {
        return this.num * 469
      }
    },

    mounted() {
      this.$nextTick(() => {
        // eslint-disable-next-line no-undef
        this.scroll = new BScroll('.body', {
          click: true,
          mouseWheel: true
        })
      })
    }
  }
</script>

<style scoped>
  .money {
    margin-bottom: 10px;
  }

  .item3-button {
    background-color: red;
    border-radius: 5px;
    margin: 3px;
    opacity: 0.8;
  }

  .item1-content2 {
    margin-top: 10px;
    margin-bottom: 10px;
  }

  .item2-content2 {
    margin-top: 10px;
    margin-bottom: 10px;
  }

  .item1-content1 {
    border-bottom: solid 1px gray;
  }

  .item2-content1 {
    border-bottom: solid 1px gray;
  }

  .item2-item2 {
    width: 440px;
    margin: 2px;
    border: solid 1px gray;
    border-radius: 5px;
    background-color: #fff;
    padding-left: 5px;
  }

  .item2-item1 {
    width: 440px;
    margin: 2px;
    border: solid 1px gray;
    border-radius: 5px;
    background-color: #fff;
    padding-left: 5px;
  }

  .top {
    position: absolute;
    width: 40px;
    height: 40px;
    bottom: 100px;
    right: 5px;
    background-color: #fff;
    border: solid 1px gray;
    border-radius: 50%;
  }

  .body-item1 {
    width: 450px;
    height: 50%;
  }

  .father {
    width: 450px;
    height: 100%;
  }

  .header {
    width: 100%;
    height: 5%;
  }

  .body {
    width: 450px;
    height: 680px;
    overflow: hidden;
    background-color: #888;
    border-bottom: solid 1px gray;
  }
</style>
